package com.trace.pplos.parse.dao.dataobject;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

public class ZdcsInfo {
    private static final Logger logger = LoggerFactory.getLogger(ZdcsInfo.class);

    private Integer id;

    private String billNo;

    private String types;

    private String title;

    private String addr;

    private String lng;

    private String lat;

    private String telI;

    private String des;

    private String photoPath;

    private String voicePath;

    private String videoPath;

    private String voiceDisplayNames;

    private String videoDisplayNames;

    private String signalStation;

    private String synced;

    private String locMapSnapPath;

    private String lngGps;

    private String latGps;

    private String licensePhotoPath;

    private String placePhotoPath;

    private String cjdw;

    private String filepath;

    private Date gmtCreate;

    private String gmtCreateUser;

    private Date gmtModified;

    private String gmtModifiedUser;

    private Integer status;

    public ZdcsInfo(Integer id, String billNo, String types, String title, String addr, String lng, String lat, String telI, String des, String photoPath, String voicePath, String videoPath, String voiceDisplayNames, String videoDisplayNames, String signalStation, String synced, String locMapSnapPath, String lngGps, String latGps, String licensePhotoPath, String placePhotoPath, String cjdw, String filepath, Date gmtCreate, String gmtCreateUser, Date gmtModified, String gmtModifiedUser, Integer status) {
        this.id = id;
        this.billNo = billNo;
        this.types = types;
        this.title = title;
        this.addr = addr;
        this.lng = lng;
        this.lat = lat;
        this.telI = telI;
        this.des = des;
        this.photoPath = photoPath;
        this.voicePath = voicePath;
        this.videoPath = videoPath;
        this.voiceDisplayNames = voiceDisplayNames;
        this.videoDisplayNames = videoDisplayNames;
        this.signalStation = signalStation;
        this.synced = synced;
        this.locMapSnapPath = locMapSnapPath;
        this.lngGps = lngGps;
        this.latGps = latGps;
        this.licensePhotoPath = licensePhotoPath;
        this.placePhotoPath = placePhotoPath;
        this.cjdw = cjdw;
        this.filepath = filepath;
        this.gmtCreate = gmtCreate;
        this.gmtCreateUser = gmtCreateUser;
        this.gmtModified = gmtModified;
        this.gmtModifiedUser = gmtModifiedUser;
        this.status = status;
    }

    public ZdcsInfo() {
        super();
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getBillNo() {
        return billNo;
    }

    public void setBillNo(String billNo) {
        this.billNo = billNo == null ? null : billNo.trim();
    }

    public String getTypes() {
        return types;
    }

    public void setTypes(String types) {
        this.types = types == null ? null : types.trim();
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title == null ? null : title.trim();
    }

    public String getAddr() {
        return addr;
    }

    public void setAddr(String addr) {
        this.addr = addr == null ? null : addr.trim();
    }

    public String getLng() {
        return lng;
    }

    public void setLng(String lng) {
        this.lng = lng == null ? null : lng.trim();
    }

    public String getLat() {
        return lat;
    }

    public void setLat(String lat) {
        this.lat = lat == null ? null : lat.trim();
    }

    public String getTelI() {
        return telI;
    }

    public void setTelI(String telI) {
        this.telI = telI == null ? null : telI.trim();
    }

    public String getDes() {
        return des;
    }

    public void setDes(String des) {
        this.des = des == null ? null : des.trim();
    }

    public String getPhotoPath() {
        return photoPath;
    }

    public void setPhotoPath(String photoPath) {
        this.photoPath = photoPath == null ? null : photoPath.trim();
    }

    public String getVoicePath() {
        return voicePath;
    }

    public void setVoicePath(String voicePath) {
        this.voicePath = voicePath == null ? null : voicePath.trim();
    }

    public String getVideoPath() {
        return videoPath;
    }

    public void setVideoPath(String videoPath) {
        this.videoPath = videoPath == null ? null : videoPath.trim();
    }

    public String getVoiceDisplayNames() {
        return voiceDisplayNames;
    }

    public void setVoiceDisplayNames(String voiceDisplayNames) {
        this.voiceDisplayNames = voiceDisplayNames == null ? null : voiceDisplayNames.trim();
    }

    public String getVideoDisplayNames() {
        return videoDisplayNames;
    }

    public void setVideoDisplayNames(String videoDisplayNames) {
        this.videoDisplayNames = videoDisplayNames == null ? null : videoDisplayNames.trim();
    }

    public String getSignalStation() {
        return signalStation;
    }

    public void setSignalStation(String signalStation) {
        this.signalStation = signalStation == null ? null : signalStation.trim();
    }

    public String getSynced() {
        return synced;
    }

    public void setSynced(String synced) {
        this.synced = synced == null ? null : synced.trim();
    }

    public String getLocMapSnapPath() {
        return locMapSnapPath;
    }

    public void setLocMapSnapPath(String locMapSnapPath) {
        this.locMapSnapPath = locMapSnapPath == null ? null : locMapSnapPath.trim();
    }

    public String getLngGps() {
        return lngGps;
    }

    public void setLngGps(String lngGps) {
        this.lngGps = lngGps == null ? null : lngGps.trim();
    }

    public String getLatGps() {
        return latGps;
    }

    public void setLatGps(String latGps) {
        this.latGps = latGps == null ? null : latGps.trim();
    }

    public String getLicensePhotoPath() {
        return licensePhotoPath;
    }

    public void setLicensePhotoPath(String licensePhotoPath) {
        this.licensePhotoPath = licensePhotoPath == null ? null : licensePhotoPath.trim();
    }

    public String getPlacePhotoPath() {
        return placePhotoPath;
    }

    public void setPlacePhotoPath(String placePhotoPath) {
        this.placePhotoPath = placePhotoPath == null ? null : placePhotoPath.trim();
    }

    public String getCjdw() {
        return cjdw;
    }

    public void setCjdw(String cjdw) {
        this.cjdw = cjdw == null ? null : cjdw.trim();
    }

    public String getFilepath() {
        return filepath;
    }

    public void setFilepath(String filepath) {
        this.filepath = filepath == null ? null : filepath.trim();
    }

    public Date getGmtCreate() {
        return gmtCreate;
    }

    public void setGmtCreate(Date gmtCreate) {
        this.gmtCreate = gmtCreate;
    }

    public String getGmtCreateUser() {
        return gmtCreateUser;
    }

    public void setGmtCreateUser(String gmtCreateUser) {
        this.gmtCreateUser = gmtCreateUser == null ? null : gmtCreateUser.trim();
    }

    public Date getGmtModified() {
        return gmtModified;
    }

    public void setGmtModified(Date gmtModified) {
        this.gmtModified = gmtModified;
    }

    public String getGmtModifiedUser() {
        return gmtModifiedUser;
    }

    public void setGmtModifiedUser(String gmtModifiedUser) {
        this.gmtModifiedUser = gmtModifiedUser == null ? null : gmtModifiedUser.trim();
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public static ZdcsInfo toBean(String object) {
        try {
            ZdcsInfo info = new ZdcsInfo();
            JSONObject record = JSON.parseObject(object);
         /*   info.setId(record.getString());
            info.setBillNo(record.getString());*/
            info.setSynced("0");
            info.setTypes(record.getString("cslx"));
            info.setTitle(record.getString("csmc"));
            info.setAddr(record.getString("address"));
            info.setLng(record.getString("longitude"));
            info.setLat(record.getString("latitude"));
            info.setTelI(record.getString("dhhm"));
            info.setDes(record.getString("bzxx"));

            //场所照片
            String photoPath = "";
            JSONArray photoPathlist = record.getJSONArray("cszpPictureList");
            for (int i = 0; i < photoPathlist.size(); i++) {
                JSONObject dataObj = photoPathlist.getJSONObject(i);
                photoPath += dataObj.getString("path") + ",";
            }
            info.setPhotoPath(photoPath);

            //语音地址
            String voicePath = "";
            String voiceDisplayNames = "";
            JSONArray voicePathlist = record.getJSONArray("voiceList");
            for (int i = 0; i < voicePathlist.size(); i++) {
                JSONObject dataObj = voicePathlist.getJSONObject(i);
                voicePath += dataObj.getString("path") + ",";
                voiceDisplayNames += dataObj.getString("name") + ",";
            }
            info.setVoicePath(voicePath);
            info.setVoiceDisplayNames(voiceDisplayNames);
/*            info.setVideoPath(record.getString());
            info.setVideoDisplayNames(record.getString());*/
            //wifiList
            String signalStation = "";
            JSONArray signalStationlist = record.getJSONArray("wifiList");
            for (int i = 0; i < signalStationlist.size(); i++) {
                JSONObject dataObj = signalStationlist.getJSONObject(i);
                signalStation += dataObj.getString("path") + ",";
            }
            info.setSignalStation(signalStation);

            //现场方位
            String locMapSnapPath = "";
            JSONArray locMapSnapPathlist = record.getJSONArray("xcfwPictureList");
            for (int i = 0; i < locMapSnapPathlist.size(); i++) {
                JSONObject dataObj = locMapSnapPathlist.getJSONObject(i);
                locMapSnapPath += dataObj.getString("path") + ",";
            }
            info.setLocMapSnapPath(locMapSnapPath);
            info.setLngGps(record.getString("longitude"));
            info.setLatGps(record.getString("latitude"));

            //营业执照照片
            String licensePhotoPath = "";
            JSONArray licensePhotoPathlist = record.getJSONArray("yyzzPictureList");
            for (int i = 0; i < licensePhotoPathlist.size(); i++) {
                JSONObject dataObj = licensePhotoPathlist.getJSONObject(i);
                licensePhotoPath += dataObj.getString("path") + ",";
            }
            info.setLicensePhotoPath(licensePhotoPath);

            //相邻照片
            String placePhotoPath = "";
            JSONArray placePhotoPathlist = record.getJSONArray("xlzpPictureList");
            for (int i = 0; i < placePhotoPathlist.size(); i++) {
                JSONObject dataObj = placePhotoPathlist.getJSONObject(i);
                placePhotoPath += dataObj.getString("path") + ",";
            }
            info.setPlacePhotoPath(placePhotoPath);

           /* info.setCjdw(record.getString());
            info.setFilepath(record.getString());*/
            info.setGmtCreate(record.getDate("createdAt"));
            info.setGmtCreateUser(record.getString("createdBy"));
            //info.setGmtModified(record.getDate("modifiedAt"));
            info.setGmtModified(new Date());
            info.setGmtModifiedUser(record.getString("modifiedBy"));
            return info;
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
        return null;
    }
}